﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using ZHDJ.Core.Util;
using ZHDJ.Data.Initializer;
using ZHDJ.Data.Initializer.JoinParty;
using ZHDJ.Data.Models.Box;
using ZHDJ.Data.Models.Edu;

namespace ZHDJ.Data
{
    public class AppBoxDatabaseInitializer : DropCreateDatabaseAlways<AppBoxContext>

    // DropCreateDatabaseAlways<AppBoxContext>  DropCreateDatabaseIfModelChanges<AppBoxContext>
    {
        protected override void Seed(AppBoxContext context)
        {
            ConfigsInit.GetConfigs().ForEach(c => context.Configs.Add(c));
            DeptInit.GetDepts().ForEach(d => context.Depts.Add(d));
            UserInit.GetUsers().ForEach(u => context.Users.Add(u));

            RoleInit.GetRoles().ForEach(r => context.Roles.Add(r));
            PowerInit.GetPowers().ForEach(p => context.Powers.Add(p));
            TitleInit.GetTitles().ForEach(t => context.Titles.Add(t));
            //GetPatyEduSpecial().ForEach(s=>context.PatyEduSpecials.Add(s));
            PartyJoinProcessInit.GetPartyJoinProcesss().ForEach(t => context.PartyJoinProcesss.Add(t));
            context.SaveChanges();
            // 添加菜单时需要指定ViewPower，所以上面需要先保存到数据库
            MenuInit.GetMenus(context).ForEach(m => context.Menus.Add(m));
        }

      


      

       
      
        private static List<PartyEduSpecial> GetPatyEduSpecial()
        {
            var configs = new List<PartyEduSpecial> {
                new PartyEduSpecial
                {
                    OrderNo = 1,
                    SpecialName="党建知识",
                     Enabled = true,
                     StudyDescription="党建知识描述 "

                },
                new PartyEduSpecial
                {
                    OrderNo = 2,
                    SpecialName="群众路线",
                     Enabled = true,
                     StudyDescription="群众路线描述 "
                },
                new PartyEduSpecial
                {
                    OrderNo = 3,
                    SpecialName="团务知识",
                     Enabled = true,
                     StudyDescription="团务知识描述 "
                }
            };

            return configs;
        }
    }
}